/**
 * 通用模块
 */
import { service, paramsQuery } from './request';

// post
export function post(param = {}, url) {
  let ret = paramsQuery(url, param);
  return service.post(ret.path, ret.body);
}

// get
export function get(param = {}, url) {
  let ret = paramsQuery(url, param);
  return service.get(url, ret.body);
}

// 登录
export function fetchLogin(param) {
  let ret = paramsQuery('/manage/api/user/login', param);
  return service.post(ret.path, ret.body);
}

// 登出
export function fetchLogout() {
  let ret = paramsQuery('/manage/api/user/logout');
  return service.post(ret.path, ret.body);
}

// 广告计划下拉
export function fetchPlanSelect(param) {
  let ret = paramsQuery('/manage/api/bus/plan/getplanlist', param);
  return service.get(ret.path, ret.body);
}

// 广告单元下拉
export function fetchUnitSelect(param) {
  let ret = paramsQuery('/manage/api/bus/unit/getunitlist', param);
  return service.get(ret.path, ret.body);
}

// 广告创意下拉
export function fetchCreativeSelect(param) {
  let ret = paramsQuery('/manage/api/bus/creative/getcreativelist', param);
  return service.get(ret.path, ret.body);
}

// adx下拉
export function fetchAdxSelect(param) {
  let ret = paramsQuery('/manage/api/bus/page/getadxbyid', param);
  return service.get(ret.path, ret.body);
}

// 媒体类型下拉
export function fetchMediaTypeSelect(param) {
  let ret = paramsQuery('/manage/api/bus/page/getcategorylist', param);
  return service.get(ret.path, ret.body);
}

// 媒体下拉
export function fetchMediaSelect(param) {
  let ret = paramsQuery('/manage/api/bus/page/getmedialist', param);
  return service.get(ret.path, ret.body);
}

// 广告位下拉
export function fetchAdLocalSelect(param) {
  let ret = paramsQuery('/manage/api/bus/page/getadspacelist', param);
  return service.get(ret.path, ret.body);
}

// 账户余额
export function fetchAccountRemain(param) {
  let ret = paramsQuery('/manage/api/bus/user/getremain', param);
  return service.post(ret.path, ret.body);
}

// 自定义字段/保存
export function fetchCustomUpdate(param) {
  let ret = paramsQuery('/manage/api/bus/page/save_field', param);
  return service.post(ret.path, ret.body);
}

// 自定义字段/获取
export function fetchCustom(param) {
  let ret = paramsQuery('/manage/api/bus/page/get_field', param);
  return service.post(ret.path, ret.body);
}

// 人群包
export function fetchCrowdList(param) {
  let ret = paramsQuery('/manage/api/bus/page/get_crowd_list', param);
  return service.post(ret.path, ret.body);
}
